home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!seacloud.demon.co.uk
- From: Ben Ashley <Ben@seacloud.demon.co.uk>
- Newsgroups: comp.lang.c++
- Subject: Re: QUESTION:Random Numbers, etc
- Date: Tue, 27 Feb 96 16:17:25 GMT
- Organization: home, in Leicester, England
- Message-ID: <825437845snz@seacloud.demon.co.uk>
- References: <4gnpic$j5s@news1.usa.pipeline.com> <4gr0hs$qck@masala.cc.uh.edu>
- Reply-To: Ben@seacloud.demon.co.uk
- X-NNTP-Posting-Host: seacloud.demon.co.uk
- X-Newsreader: Demon Internet Simple News v1.29
- X-Mail2News-Path: seacloud.demon.co.uk
-
- In article <4gr0hs$qck@masala.cc.uh.edu> txs53132@bayou.uh.edu "Sensarn" writes:
-
- > The actual BASIC formula (figured this one out myself) is:
- >
- > INT(RND*(MAX-MIN+1)+MIN)
- >
- > The TC++ 3.1 function random() can be used to generate a similar effect:
- >
- > random(max-min+1)+min;
- >
- > Hope VC++ has random()!
-
- I use MSVC 1.00. It does not have random(), but it has rand() which generates
- a stupid number! To get it in a range, you have to use the modulus '%'
- operator.
-
- To get a number between 1 and 16, you use 'rand() % 17'. Or something like
- that anyway!
-
- --
- Cheers,
-
- Ben
-
- ------------------====### legal notice ###====-----------------------
- Microsoft Network is prohibited from redistributing this work in any
- form,in whole or in part. License to distribute this post is available to
- Microsoft for $499. Posting without permission constitutes an agreement to
- these terms.
-